﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<IPagedList<MensUnoShop.Models.OrderData>>" %>
<%@ Import Namespace="MvcPaging"%>  
<%@ Import Namespace="MensUnoShop.Helpers" %>
<%@ Import Namespace="MensUnoShop.Areas.Admin.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
待入帳訂單
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" language="javascript">
    function changestatus(oguid, tostatus) {
        var jsonstring = { "oguid": oguid, "orderstatus": tostatus };
        $.ajax({
            type: "POST",
            traditional: true,
            url: "/Admin/OrderManagement/OrderStatusChange",
            data: jsonstring,
            dataType: "json",
            success: function (data) {
                if (data.code == "200") {
                    alert("狀態變更成功!");
                    $("#tr_" + oguid).remove();                                        
                }
                else
                    alert(data.response); 
                    //location.reload();
            }
        });
    }

</script>
<div id="main-content" class="hastable" style="margin:0 auto;">
		    <div class="title title-spacing">
			    <h2>待入帳訂單</h2>
					依下列條件查詢所有待入帳訂單
		    </div>
            <%using (Html.BeginForm("GetOrder", "OrderManagement", FormMethod.Post, new { @class = "shBox" }))
             {%>
             <select id="querychoice" name="querychoice" class="field">
                 <option value="queryall">不限條件</option>
                 <option value="querytxid">訂單編號</option>
                 <option value="querycashid">金流編號</option>
                 <option value="queryemail">會員帳號(E-Mail)</option>
                 <option value="querymname">會員姓名</option>
             </select>
             <%:Html.Hidden("querytype", "waiting")%>
             <input type="text" id="querycontent" name="querycontent" />
            <input type="submit" class="submit" value="查詢訂單" />
            <%} %>
            <%if (Model != null && Model.Count > 0)
              {%>
              <input type="button" id="getexcel" name="getexcel" value="匯出" onclick="javascript:location.href='GetExcel/WaitingList';" />
            <%} %>
            <ul class="pagination">
                <%= Html.UPager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)%>
            </ul>
            <table  cellspacing="0">
            <thead>
        	    <tr>
                    <th width="80"></th>
                    <th width="80"></th>
                    <th width="80">訂單編號</th>
                    <th>會員帳號(E-Mail)</th>
                    <th width="80">會員姓名</th>
                    <th width="60">消費金額</th>
                    <th width="140">運送方式</th>
                    <th width="140">付費方式</th>
                    <th width="80">金流編號</th>
                    <th width="80">訂單日期</th>
                    <th width="100">客戶意見</th>
                    <th width="80">訂單明細</th>
                    <th width="80">會員資料</th>
                </tr>            
            </thead>        
        
            <%if (Model != null)
                {%>           
            <tbody>
                <%foreach (var item in Model)
                {  %>
        	    <tr id="tr_<%:item.OGUID %>" name="tr_<%:item.OGUID %>">
                    <td><input type="button" name="changestatusPaid" id="changestatusPaid" value="手動入帳" onclick="javascript:changestatus('<%:item.OGUID %>','3');" /></td>
                    <td><input type="button" name="changestatusCancel" id="changestatusCancel" value="取消訂單" onclick="javascript:changestatus('<%:item.OGUID %>','7');" /></td>
                    <td><%:item.OTXID %></td>
                    <td><%:item.MEMAIL %></td>
                    <td><%:item.MNAME %></td>
                    <td><%:item.ORDERPRICE %></td>
                    <td><%=Html.GetShippingWay(item.OSHIPPINGWAY)%></td>
                    <td><%=Html.GetPayType(item.PAYTYPE)%></td>
                    <td><%:item.OCASHID %></td>
                    <td><%:item.ORDERDATE.ToString("yyyy/MM/dd HH:mm:ss")%></td>
                    <td><%:item.RCCUSTOMER%></td>
                    <td><a id="OrderDetail" name="OrderDetail" class="iframe" target="_blank" href="OrderDetailView/<%:item.OGUID %>">訂單明細</a></td>
                    <td><a id="MemberDetail" name="MemberDetail" class="iframe" target="_blank" href="../MemberManagement/MemberDetailView/<%:item.MGUID %>">會員資料</a></td>                
                </tr>
                <%} %>
            </tbody>
            <%} %>
        </table>
            <ul class="pagination" style="margin-top:-60px;">
                <%= Html.UPager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)%>
            </ul>
        </div>

<script type="text/javascript">
   $("a#OrderDetail").fancybox({ width: 810 });
   $("a#MemberDetail").fancybox({ height: 400, scrolling: 'no' });
</script>
</asp:Content>
